﻿
#ifndef Base_MessageCore_h__
#define Base_MessageCore_h__

#include <thread>
#include <map>
#include "ConfDef.h"

class Base_Monitor;
class Base_GlobalQueue;
class Base_Context;

class Base_MessageCore
{

public:
	bool start(const Config & conf);
	void quit();
	static Base_MessageCore * get_instance();
	/*
	@type   消息类型  
	@src     源
	@des      目标地址  
	*/
	void send_msg( uint32_t type,uint32_t src,uint32_t des,void * data,int size);

	static void register_context(Base_Context *context);
private:
	Base_MessageCore();
	~Base_MessageCore();
	void worker();
private:
	Base_Monitor * m_monitor;
	int m_thread_work_count;
	std::thread**  m_thread_arr;   //线程指针数组 
	bool m_start;
	Base_GlobalQueue * m_gmq;  
	
	static std::map<uint32_t, Base_Context *> m_map_context;
};


#endif // Base_MessageCore_h__